package com.PopulateDB;

import java.sql.Connection;
import java.util.Date;

import com.CMUBiS.util.Address;
import com.CMUBiS.util.Bid;

public abstract class DBPopulator {
	private String url = null;
	private String driver = null;
	private String username = null;
	private String password = null;
	
	protected DBPopulator(String url, String driver, String username, String password){
		init(url, driver, username, password);
	}
	
	protected DBPopulator(String fileName){
		//TODO: Read the values from a file
		//TODO: call init
		String url = "jdbc:mysql://10.9.78.1/cmubis";
		String driver = "com.mysql.jdbc.Driver";
		String username = "root";
		String password = "testtest";
		
		init(url, driver, username, password);
	}
	
	private void init(String url, String driver, String username, String password){
		this.url = url;
		this.driver = driver;
		this.username = username;
		this.password = password;
	}
	
	protected String getURL(){
		return this.url;
	}
	
	protected String getDriver(){
		return this.driver;
	}
	
	protected String getUsername(){
		return this.username;
	}
	
	protected String getPassword(){
		return this.password;
	}
	
	public abstract Connection getConnection();
	
	public abstract void closeConnection();
	
	public abstract int insertUser(String firstName, String lastName, String username, String password, String email, int rating, Date creationDate);
		
	public abstract boolean dropAddUsers();
	
	public abstract int insertItem(String name, String description, float startPrice, int quantity, float reservePrice, float buyNowPrice, Date startDate, Date endDate, int sellerID, int categoryID);
	
	public abstract boolean dropAddItems();
	
	public abstract int insertBid(Bid bid, int itemID);
	
	public abstract boolean dropAddBids();
	
	public abstract void updateItemMaxBid(int itemID, int noOfBids, float currentBid, float maxBid, int currentWinner);
	
	public abstract int insertAddress(Address address);
	
	public abstract boolean dropAddAdresses();
	
	public abstract int insertCategory(int id, String name, int parent);
	
	public abstract boolean dropAddCategories();
	
	public abstract boolean dropAddImages();
	
	public abstract boolean dropAddItemImage();
	
	public abstract boolean dropAddPayments();
	
	public abstract boolean dropAddPurchased();
	
	public abstract boolean dropAddStates();
	
	public abstract int insertState(String shortName, String longName);
}
